typedef double Vector[N];

typedef struct {
    Vector history[M];
} VectorHistory;

void vhInit(VectorHistory*vh){
    int i,j;
    for (j=0; j<M; ++j){
        for (i=0; i<N; ++i){
            vh->history[j][i] = 0;
        }
    }
}

void vhPush(VectorHistory*vh, Vector v){
    int i;
    memmove(vh->history+1, vh->history, (M-1)*sizeof(Vector));
    for (i=0; i<N; ++i){
        vh->history[0][i] = v[i];
    }
}

void vhPrint(VectorHistory*vh){
    int i,j;
    //printf("vh\n");
    for (j=0; j<M; ++j){
        printf("[ %d", M);
        for (i=0; i<N; ++i){
            printf("%12g ", vh->history[j][i]);
        }
        printf("]\n");
    }
}
